package com.dp.mallchat.common.user.controller;


import com.dp.mallchat.common.common.domain.vo.resp.ApiResult;
import com.dp.mallchat.common.common.utils.RequestHolder;
import com.dp.mallchat.common.user.domain.user.req.UserEmojiDeleteReq;
import com.dp.mallchat.common.user.domain.user.req.UserEmojiSaveReq;
import com.dp.mallchat.common.user.domain.user.resp.UserEmojiResp;
import com.dp.mallchat.common.user.service.UserEmojiService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 用户表情包 前端控制器
 * </p>
 *
 * @author <a href="https://gitee.com/baiDP">adu</a>
 * @since 2024-07-18
 */
@RestController
@RequestMapping("/capi/user/emoji")
@Api(tags = "用户表情包管理相关接口")
public class UserEmojiController {

    @Autowired
    private UserEmojiService userEmojiService;

    @GetMapping("/list")
    public ApiResult<List<UserEmojiResp>> listEmoji(){
        return ApiResult.success(userEmojiService.listEmoji(RequestHolder.getThreadLocal().getUid()));
    }

    @PostMapping
    public ApiResult<Void> saveEmoji(@Valid  @RequestBody UserEmojiSaveReq req){
        userEmojiService.saveEmoji(RequestHolder.getThreadLocal().getUid(), req);
        return ApiResult.success();
    }

    @DeleteMapping
    public ApiResult<Void> deleteEmoji(@Valid  @RequestBody UserEmojiDeleteReq req){
        userEmojiService.deleteEmoji(RequestHolder.getThreadLocal().getUid(), req);
        return ApiResult.success();
    }
}

